home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / doors_1 / doorskl3.zip / XBBSMSG.ZIP / MISCMSG.C < prev    next >
C/C++ Source or Header  |  1991-08-11  |  2KB  |  59 lines

  1. /* Misc. XBBS message base functions */
  2.  
  3. #ifndef __TURBOC__
  4.     #define INCL_DOS
  5.     #include <os2.h>            /* for DosSleep() */
  6.     #include <sys/locking.h>
  7. #endif
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <io.h>
  11. #include <fcntl.h>
  12. #include <share.h>
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include <string.h>
  16. #include <errno.h>
  17. #include "xmsg.h"
  18.  
  19. #ifdef __TURBOC__
  20.     #define LK_LOCK     1
  21.     #define LK_UNLCK    2
  22.     #define DosSleep(x) sleep(1)
  23.     /* replacement for MSC's locking() in this module */
  24.     int pascal locking (int handle,int type,long length);  
  25.     #define _fastcall pascal
  26. #endif
  27.  
  28.  
  29. /* external variables referenced */
  30.  
  31. extern char *msgpath;
  32.  
  33.  
  34.  
  35. unsigned int _fastcall how_many_msgs (unsigned int areano) {
  36.  
  37.     /* returns number of messages in an area */
  38.  
  39.     unsigned int tempsize;
  40.     struct stat  st;
  41.     char         filename[257];
  42.  
  43.  
  44.     sprintf(filename,"%sXDATA.%03x",msgpath,areano);
  45.     if(stat(filename,&st)) tempsize = 0;
  46.     else tempsize = (unsigned int)(st.st_size / (long)sizeof(XMSG));
  47.     if(tempsize) {
  48.         sprintf(filename,"%sXTEXT.%03x",msgpath,areano);
  49.         if(stat(filename,&st)) {
  50.             tempsize = 0;
  51.             sprintf(filename,"%sXDATA.%03x",msgpath,areano);
  52.             unlink(filename);   /* eliminate orphaned header file */
  53.                                 /* note you may want to check for and */
  54.                                 /* try to restore an XTBAK.### file first */
  55.     }
  56.     return tempsize;
  57. }
  58.  
  59.